<template>
  <div class="messages">
    <div class="alert-message" :class="[{ 'alert-message-back': messageTitle === '' }]">
      <h3>{{ messageTitle }}</h3>

      <van-picker :show-toolbar="false" :columns="columns" @confirm="onConfirm" @cancel="onCancel" item-height="4.2rem"
        @change="onChange" :default-index="defaultIndex" visible-item-count="5" ref="picker" />
      <div class="alert-btn">
        <div @click="shadeHide">
          <p>{{ $t("cancel") }}</p>
        </div>
        <div class="line"></div>
        <div @click="deleteTrue">
          <p v-if="!isUpdate">{{ $t("sure") }}</p>
          <p v-if="isUpdate">{{ $t("touchOK") }}</p>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { mapState } from "vuex";
export default {
  name: "cell",
  components: {},
  props: {
    messageTitle: {
      type: String,
      default: "",
    },
    messageText: {
      type: String,
      default: "",
    },
    isUpdate: {
      type: Boolean,
      default: false,
    },
    isInput: {
      type: Boolean,
      default: false,
    },
    clickFlag: {
      type: Number,
      default: 1,
    },
    defaultValue: {
      
      default: 1,
    },

  },
  data() {
    return {
      center: false,
      detailDom: "",
      inputName: "",
      defaultIndex: 3,
    };
  },
  computed: {
    ...mapState({
     
    }),
    columns() {
      let arr = [];
      for (let i = 0; i <= 23; i++) {
        if (i < 10) i = "0" + i
        arr.push(i + " " +  this.$t('translate81'));
      }

      let arr2 = [];
      for (let i = 0; i <= 59; i++) {
        arr2.push(i + " " + this.$t('translate61'));
      }

      let hour = parseInt(this.defaultValue / 60);
      let min = parseInt(this.defaultValue % 60)
      let arr3 = [
        { values: arr, defaultIndex: hour },
        { values: arr2, defaultIndex: min },
      ];

      return arr3;
    },
  },
  methods: {
    shadeHide() {
      this.$emit("shadeHide");
    },
    deleteTrue() {
      let value = this.$refs.picker.getValues();
      this.$emit("deleteTrue", value);
    },
    onConfirm(value, index) {
      //alert(`当前值：${value}, 当前索引：${index}`);
    },
    onChange(picker, value, index) {
      //alert(`当前值：${value}, 当前索引：${index}`);
    },
    onCancel() {
      // alert('取消');
    },
    showDetailBtnFun() {
      if (this.isUpdate === false) {
        this.$nextTick(() => {
          this.detailDom = this.$refs.detailDom;
          if (this.detailDom.clientHeight < 30) {
            this.center = true;
          } else {
            this.center = false;
          }
        });
      }
    },
  },
  mounted() {
    // this.defaultValue &&
    //   (this.defaultIndex = this.columns.indexOf(this.defaultValue));
  },
};
</script>

<style scoped lang="less">
@media only screen and (min-width: 600px) and (max-width: 800px) {
  .alert-message {
    left: calc(25% + 1.2rem) !important;
    right: calc(25% + 1.2rem) !important;
    bottom: 50% !important;
    transform: translateY(50%);
  }
}

@media only screen and (min-width: 800px) {
  .alert-message {
    left: calc(25% + 1.2rem) !important;
    right: calc(25% + 1.2rem) !important;
    bottom: 50% !important;
    transform: translateY(50%);
  }
}

.messages {
  position: absolute;
  top: 0;
  height: 100%;
  width: 100%;
  z-index: 199999991;
  background: rgba(0, 0, 0, 0.2);
}

.alert-message {
  position: fixed;
  bottom: 1.6rem;
  left: 1.2rem;
  right: 1.2rem;
  background: #ffffff;
  border-radius: 2.4rem;
  z-index: 111;
  transition: all 0.5s;
  -webkit-animation: actionsheet 400ms ease-in-out 0ms;
  animation: actionsheet 400ms ease-in-out 0ms;
  color: #000;
}

.alert-message h3 {
  font-size: 2rem;
  font-weight: normal;
  text-align: left;
  height: 2.6rem;
  line-height: 2.6rem;
  padding: 1.6rem 2.4rem 1.4rem 2.4rem;
}

.alert-message .messipt {
  margin: 0.4rem 0;
}

/* .alert-message-back {
  padding-top: 2.4rem;
} */

.alert-message .message-p {
  font-size: 1.6rem;
  line-height: 2.2rem;
  min-height: 2.2rem;
  color: rgba(0, 0, 0, 0.9);
  text-align: left;
  box-sizing: border-box;
  padding: 0 2.4rem;
}

.alert-message .message-center {
  text-align: center;
}

.alert-btn {
  display: flex;
  color: #0a59f7;
  font-size: 1.6rem;
  height: 5.6rem;
  justify-content: center;
  text-align: center;
  line-height: 5.6rem;
  margin-top: 0.8rem;
}

.alert-btn div {
  font-weight: 400;
  height: 4rem;
  width: 14.4rem;
  font-size: 1.6rem;
  text-align: center;
  line-height: 4rem;
}

.alert-btn div p {
  width: 100%;
  height: 4rem;
  line-height: 4rem;
  border-radius: 0.3rem;
}

#app .alert-btn div .delete {
  color: #fa2a2d !important;
}

.disabled {
  opacity: 0.38 !important;
  pointer-events: none;
}

.alert-btn div p:active {
  margin: 0 auto;
  background-color: rgba(0, 0, 0, 0.05) !important;
}

@keyframes actionsheet {
  0% {
    bottom: -100%;
  }

  to {
    bottom: 1rem;
  }
}

.line {
  width: 1px;
  height: 2.4rem !important;
  position: relative;
  top: 0.8rem;
  flex: 0 !important;
  background: rgba(0, 0, 0, 0.2);
  margin: 0 0.8rem;
}

.line::after {
  content: "";
  width: 200%;
  height: 200%;
  position: absolute;
  left: 0;
  background: rgba(0, 0, 0, 0.2);
  top: 0;
  border-right: 0.1rem solid rgba(0, 0, 0, 0.2);
  transform: scale(0.5, 0.5);
  transform-origin: top left;
}

.dark .line::after {
  content: "";
  width: 200%;
  height: 200%;
  position: absolute;
  top: 0;
  left: 0;
  background: rgba(255, 255, 255, 0.2);
  transform: scale(0.5);
  transform-origin: top left;
}

.dark .messages {
  background: rgba(0, 0, 0, 0.4);
}

.dark .alert-message {
  background: var(--emui_popup_bg);
}

.dark .alert-message h3 {
  color: rgba(255, 255, 255, 0.9);
}

.dark .alert-message .message-p {
  color: rgba(255, 255, 255, 0.86);
}

#app .dark .alert-btn div .delete {
  color: #d94838 !important;
}

.dark .alert-btn {
  color: #5291ff;
}

input {
  width: calc(100% - 4.8rem);
  height: 4.8rem;
  /* background: #f6f7f7; */
  /* border-radius: 2.4rem; */
  opacity: 1;
  border: 0;
  border-bottom: 0.025rem solid #e6e6e6;
  margin-left: 2.6rem;
  /* text-indent: 2.2rem; */
}

.dark input {
  background: var(--emui_popup_bg);
  border-bottom: 0.025rem solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.9);
}

/deep/ li.van-picker-column__item.van-picker-column__item--selected {
  color: #0a57f9;
  font-size: 2rem;
}

/deep/ .van-picker__mask {
  background-image: var(--gradient_picker);
}

/deep/.van-hairline-unset--top-bottom.van-picker__frame {
  top: 11rem;
  height: 5.6rem !important;
  left: 0.3rem;
  right: 0.3rem;
}

/deep/.van-picker__columns {
  height: 20.8rem !important;
  width: calc(100% - 4.8rem) !important;
  margin: 0 auto;
}

// /deep/.van-picker-column__wrapper {
//   width: 14.4rem !important;
// }
/deep/ .van-picker-column__item {
  color: var(--emui_text_primary);
  font-size: 1.6rem;
  // width: 14.4rem;
  padding: 0;
}

/deep/.van-picker-column__item--selected {
  color: var(--xwq_color) !important;
}

/deep/ li.van-picker-column__item.van-picker-column__item--selected {
  color: #0a57f9;
  font-size: 2rem;
  height: 5.6rem !important;
  line-height: 5.6rem !important;
}

/deep/.van-picker-column {
  background-image: var(--gradient_picker);
}

/deep/.van-hairline-unset--top-bottom::after {
  position: absolute;

  // top: -50%;
  // left: -50%;
  // bottom: -50%;
  // position: absolute;
  // bottom: 0;
  z-index: -1;
  // width: 200%;
  // height: 200%;
  content: "";
  display: block;
  border: 1px solid var(--emui_color_list_divider);
  border-left: 0;
  border-right: 0;
  /* border-radius: 10px; */
  // transform: scale(0.45);
}</style>
